<style scoped src="./index.scss" lang="scss" rel="stylesheet/scss"></style>
<template src="./index.html"></template>
<script>
export default {
  mixins: [Vue.prototype.$vFN.Mixins.Base, Vue.prototype.$vFN.Mixins.Edit],
  components: {},
  data() {
    return {
        appWindow: window,
      form: {
        rightName: "", //权益名称
        rightType: 4, //类型
        remark: "", //文本框
      },
      // 页面接口地址
      apiUrl: {
        create: "mall-site-portal/member-rights/create",
        update: "mall-site-portal/member-rights/update",
        detail: "mall-site-portal/member-rights/getItem",
      },

      // dialogTitle: "添加权益", //弹窗标题
    };
  },
  methods: {
    // 初始化

    async init() {
      // if (this.type == "4") {
      //   this.form.rightType = "自定义";
      // } else if (this.type == "3") {
      //   this.form.rightType = "运费减免";
      // } else if (this.type == "2") {
      //   this.form.rightType = "订单折扣";
      // } else if (this.type == "1") {
      //   this.form.rightType = "商品折扣";
      // }

      // if (this.updateType == "detail") {
      //   this.getPowerDetail();
      //   this.dialogTitle = "修改权益";
      // }

      await this.mixinEdit_editBoxInit({
        model: "form",
        id: this.id, //从power/home传来
      });

      // 显示窗口
      this.mixinEdit_editVisible = true;
    },

    // 获取详情
    // async getPowerDetail() {
    //   let res = await this.$vFN.Http.post({
    //     url: this.apiUrl.detail,
    //     data: {
    //       id: this.id,
    //     },
    //   });

    //   if (res._ok) {
    //     const { rightName, rightType, remark } = res.data;
    //     this.form.rightName = rightName;
    //     this.form.textarea = remark;
    //   }
    // },

    // async submit() {
    //   let dataObj = {
    //     remark: this.form.textarea,
    //     rightName: this.form.rightName,
    //     rightType: this.type, // home页面传来的
    //     id: this.id, // home页面传来的
    //   };

    //   let _url = "";

    //   if (this.updateType == "detail") {
    //     dataObj.isOpen = this.isOpen; // home页面传来的
    //     _url = this.apiUrl.update;
    //   } else if (this.updateType == "add") {
    //     _url = this.apiUrl.create;
    //   }

    //   let res = await this.$vFN.Http.post({
    //     url: _url,
    //     data: dataObj,
    //   });

    //   if (res._ok) {
    //     this.$vFN.Tools.messageSuccess(res.message);
    //     this.mixinEdit_editVisible = false;
    //     this.onSuccess();
    //   }
    // },
    // 成功回调
    onSuccess() {},
    // 取消回调
    onCancel() {},
    // 失败回调
    onError() {},
  },
  mounted() {
    this.init();
  },
  activated() {},
  filters: {
    num2rightType(num) {
      if (num == 4) {
        return "自定义";
      } else if (num == 3) {
        return "运费减免";
      } else if (num == 2) {
        return "订单折扣";
      } else if (num == 1) {
        return "商品折扣";
      }
    },
  },
};
</script>
